<@admin.header title="选择纳税人">
</@admin.header>
    <body>
        <div class="rightinfo">
        	<div class="formbody">
		        <div class="formtitle">
		            <span>选择纳税人</span>
		        </div>
				<ul class="forminfo">
		            <li>
		            	<input type="hidden" id="startId" value="0" />
		                <label class="field">名称/电话号码</label>
		                <input id="keyword" type="text" class="dfinput" onkeyup="javascript:if(event.keyCode==13) search();"/>
						<button class="btn" onclick="search();">搜索</button>
		            </li>
				</ul>
			</div>
        	<!--默认查询表单-->
			<div style="overflow-y:scroll;height:400px;">
            <table class="tablelist">
                <thead>
                    <tr>
						<th width="60">编号<i class="sort"><img src="${base}/resources/images/px.gif" /></i></th>
						<th>纳税人名称</th>
                        <th>纳税人代码</th>
                        <th>注册登记类型</th>
                        <th>经营联系电话</th>
                        <th>生产经营地址</th>
						<th width="80"><input onchange="toggle(this);" type="checkbox"/></th>
                    </tr>
                </thead>
				<tbody id="contact_body">
                </tbody>
            </table>
			</div>
			<div>
				<a style="float:right;" class="ibtn" href="javascript:loadMore();">加载更多</a>
			</div>
			<div class="clear"></div>
			<div class="xline"></div>
			<div style="text-align:center;margin-top:10px;">
				<button class="btn" onclick="ok();">选择完成</button>
				<button class="btn" onclick="cancel();">关闭窗口</button>
			</div>
        </div>
    </body>
	<script>
	var keyword = "";
	var form = new App.common.form();
	var ajax = new App.common.ajax();
	var dialog = new App.common.dialog();
	
	function toggle(o){form.checkToggle('contact',o);}
	$(document).ready(function(){
		loadMore();
	});
	function search(){
		keyword =$("#keyword").val();
		$("#startId").val('0');
		$("#contact_body").html("");
		loadMore();
	}
	
	function loadMore(){
		var startId = $("#startId").val();
		ajax.post("externalcontact/select.do",{"totalCount":startId,"keyword":keyword},null,function(d){
			if(App.isEmpty(d)){
				dialog.alert("没有更多了");				
			}else{
				$('#contact_body').append(d);
				$("#startId").val($("#contact_body tr:last").attr("cid"));
			}
		});
	}
	
	function cancel(){
		dialog.confirm("确定关闭窗口吗？",function(){
			window.close();
		});
	}
	
	function ok(){
		var ids='', names='',tels='';
		$("input[name=contact]").each(function() {
			if(this.checked){
				ids+=$(this).val()+" ";
				names+=$(this).attr("uname")+" ";
				tels+=$(this).attr("tel")+" ";
			}
		});
		console.log(ids +" names="+names+" tels="+tels);
		if(App.isEmpty(ids)){
			dialog.alert("没有选中的值，请先选择");return false;
		}
		opener.${func!'contactBack'}($.trim(ids),$.trim(names),$.trim(tels));
		window.close();
	}
	</script>
</html>